package cn.yitun.chat.yitunserverrunsingleboot.startup;

import cn.yitun.chat.yitunchatbasesdk.config.HandlerActionDispatcher;
import cn.yitun.chat.yitunchatbasesdk.server.im.dispatcher.handler.SessionHandler;
import cn.yitun.chat.yitunchatbasesdk.server.im.dispatcher.handler.SessionMessageHandler;
import cn.yitun.chat.yitunchatbasesdk.server.im.dispatcher.handler.impl.SessionMessageHandlerImpl;
import cn.yitun.chat.yitunservernetcore.socket.SessionHandlerImpl;
import cn.yitun.chat.yitunserverrunsingleboot.chat.common.box.HandlerActionBox;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Date 2019-01-17 21:54:43
 * Description 主分发器配置
 * @author yitun
 * @since 1.0.0
 */
@Configuration
public class MainDispatcherConfig {

	@Bean
	public SessionMessageHandler messageHandler(HandlerActionDispatcher ad) {
		SessionMessageHandler bean = new SessionMessageHandlerImpl(ad);
		return bean;
	}

	@Bean
	public SessionHandler sessionHandler() {
		SessionHandler bean = new SessionHandlerImpl();
		return bean;
	}

	@Bean
	public HandlerActionDispatcher mainActionDispatcher(HandlerActionBox hab) {
		HandlerActionDispatcher ad = new HandlerActionDispatcher(hab);
		ad.getActionRegistry().setSeparator("/");
		ad.scan("cn.yitun.chat.yitunserverimapicore.business.*.action","cn.yitun.chat.yitunservernetcore.server.general.main.business.system.action");
		ad.addActionValidator("classpath*:/validator/main/action/*.json");
		return ad;
	}

	@Bean
	public HandlerActionBox actionBox() {
		HandlerActionBox bean = new HandlerActionBox();
		return bean;
	}
}
